﻿using SqlSugar;

namespace Zhp.SqlSugar.Entity
{
    /// <summary>
    /// 包含主键，创建，修改，删除额外字段
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    /// <typeparam name="TKey"></typeparam>
    public class BaseEntity<TEntity, TKey> : RootEntity<TEntity, TKey>, IBaseEntity where TEntity : BaseEntity<TEntity, TKey>, new()
    {
        /// <summary>
        /// 创建者名称
        /// </summary>
        [SugarColumn(IsNullable = true, IsOnlyIgnoreUpdate = true, ColumnDescription = "创建者账号")]
        public virtual string CreateBy { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(IsNullable = true, IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")]
        public virtual DateTime? CreateTime { get; set; }

        /// <summary>
        /// 更新者名称
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "更新者账户")]
        public virtual string UpdateBy { get; set; }

        /// <summary>
        /// 最后更新时间
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "更新时间")]
        public virtual DateTime? UpdateTime { get; set; }
    }

    public interface IBaseEntity
    {
        /// <summary>
        /// 创建者名称
        /// </summary>
        public string CreateBy { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreateTime { get; set; }

        /// <summary>
        /// 更新者名称
        /// </summary>
        public string UpdateBy { get; set; }

        /// <summary>
        /// 最后更新时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }
    }
}
